aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-06-28 21:59:07 +0000
committerChris Lattner <sabre@nondot.org>2010-06-28 21:59:07 +0000
commit8ff296496de0970c8d6d72320a1427a926d7ef14 (patch)
treec7d6dc187f3426532e325f7d3e4c19b001537daa /lib/CodeGen/TargetInfo.cpp
parent1090a9ba0902380dbd97d0a500daa4c373712df9 (diff)
pass/return structs of char and short as i8/i16 to avoid
aweful through-memory coersion, just like we do for i32 now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107078 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TargetInfo.cpp')
-rw-r--r--lib/CodeGen/TargetInfo.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
index 7c75891747..80163b3772 100644
--- a/lib/CodeGen/TargetInfo.cpp
+++ b/lib/CodeGen/TargetInfo.cpp
@@ -1116,11 +1116,15 @@ ABIArgInfo X86_64ABIInfo::getCoerceResult(QualType Ty,
return (Ty->isPromotableIntegerType() ?
ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
- // If this is a 32-bit structure that is passed as an int64, then it will be
- // passed in the low 32-bits of a 64-bit GPR, which is the same as how an
- // i32 is passed. Coerce to a i32 instead of a i64.
- if (Context.getTypeSizeInChars(Ty).getQuantity() == 4)
- CoerceTo = llvm::Type::getInt32Ty(CoerceTo->getContext());
+ // If this is a 8/16/32-bit structure that is passed as an int64, then it
+ // will be passed in the low 8/16/32-bits of a 64-bit GPR, which is the same
+ // as how an i8/i16/i32 is passed. Coerce to a i8/i16/i32 instead of a i64.
+ switch (Context.getTypeSizeInChars(Ty).getQuantity()) {
+ default: break;
+ case 1: CoerceTo = llvm::Type::getInt8Ty(CoerceTo->getContext()); break;
+ case 2: CoerceTo = llvm::Type::getInt16Ty(CoerceTo->getContext()); break;
+ case 4: CoerceTo = llvm::Type::getInt32Ty(CoerceTo->getContext()); break;
+ }
} else if (CoerceTo->isDoubleTy()) {
assert(Ty.isCanonical() && "should always have a canonical type here");