diff options
author | Dan Gohman <sunfish@mozilla.com> | 2014-03-03 14:08:08 -0800 |
---|---|---|
committer | Dan Gohman <sunfish@mozilla.com> | 2014-03-03 15:00:22 -0800 |
commit | f92a8f0ef8f7b349d653e97a8fb154719ef6117f (patch) | |
tree | e38f004095843685d7405f37c4078cd3c8a10af9 /lib | |
parent | d2556a585b3695704cc385a1edb80851bebc3cb1 (diff) |
Fix handling of byval arguments to set the alignment properly.
Also, fix the way we override DefaultABIInfo methods, since
classifyArgumentType and classifyReturnType are not actually virtual.
Also, DefaultABIInfo does the right thing for floating-point types,
so we don't need to special-case them.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/TargetInfo.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 7d0d1768ed..196596d40a 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -421,7 +421,16 @@ class EmscriptenABIInfo : public DefaultABIInfo { explicit EmscriptenABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {} ABIArgInfo classifyReturnType(QualType RetTy) const; - ABIArgInfo classifyArgumentType(QualType RetTy) const; + ABIArgInfo classifyArgumentType(QualType Ty) const; + + // DefaultABIInfo's classifyReturnType and classifyArgumentType are + // non-virtual, but computeInfo is virtual, so we overload that. + virtual void computeInfo(CGFunctionInfo &FI) const { + FI.getReturnInfo() = classifyReturnType(FI.getReturnType()); + for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end(); + it != ie; ++it) + it->info = classifyArgumentType(it->type); + } }; class EmscriptenTargetCodeGenInfo : public TargetCodeGenInfo { @@ -433,15 +442,12 @@ class EmscriptenTargetCodeGenInfo : public TargetCodeGenInfo { /// \brief Classify argument of given type \p Ty. ABIArgInfo EmscriptenABIInfo::classifyArgumentType(QualType Ty) const { if (isAggregateTypeForABI(Ty)) { + unsigned TypeAlign = getContext().getTypeAlignInChars(Ty).getQuantity(); if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, CGT)) - return ABIArgInfo::getIndirect(0, RAA == CGCXXABI::RAA_DirectInMemory); - return ABIArgInfo::getIndirect(0); + return ABIArgInfo::getIndirect(TypeAlign, RAA == CGCXXABI::RAA_DirectInMemory); + return ABIArgInfo::getIndirect(TypeAlign); } - // We can handle floating-point values directly. - if (Ty->isFloatingType()) - return ABIArgInfo::getDirect(); - // Otherwise just do the default thing. return DefaultABIInfo::classifyArgumentType(Ty); } @@ -454,10 +460,6 @@ ABIArgInfo EmscriptenABIInfo::classifyReturnType(QualType RetTy) const { return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0))); } - // We can handle floating-point values directly. - if (RetTy->isFloatingType()) - return ABIArgInfo::getDirect(); - // Otherwise just do the default thing. return DefaultABIInfo::classifyReturnType(RetTy); } |