summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-11-05 22:42:46 +0000
committerManman Ren <mren@apple.com>2012-11-05 22:42:46 +0000
commit505d68ffb846681f7d9aaf531a0b86a08baca6a8 (patch)
treedd89ce2dc5ea39ae73331e147ae120b95ca0dcf0 /clang/lib/CodeGen/TargetInfo.cpp
parentb1b0ab41e79f4f11ab21e6e56ded7147241f8615 (diff)
downloadbcm5719-llvm-505d68ffb846681f7d9aaf531a0b86a08baca6a8.tar.gz
bcm5719-llvm-505d68ffb846681f7d9aaf531a0b86a08baca6a8.zip
ARM byval: when type alignment is bigger than ABI alignment, we can't guarantee
the type alignment of the byval argument. This patch will disable byval in this case, it also increases the size threshold for turning on byval. A backend fix will be attempted. rdar://12596507 llvm-svn: 167416
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index f07e9548b15..90603371805 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -3220,8 +3220,16 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, int *VFPRegs,
}
// Support byval for ARM.
- if (getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(64) ||
- getContext().getTypeAlign(Ty) > 64) {
+ // The ABI alignment for APCS is 4-byte and for AAPCS at least 4-byte and at most 8-byte.
+ // Byval can't handle the case where type alignment is bigger than ABI alignment.
+ // We also increase the threshold for byval due to its overhead.
+ uint64_t ABIAlign = 4;
+ uint64_t TyAlign = getContext().getTypeAlign(Ty) / 8;
+ if (getABIKind() == ARMABIInfo::AAPCS_VFP ||
+ getABIKind() == ARMABIInfo::AAPCS)
+ ABIAlign = std::min(std::max(TyAlign, (uint64_t)4), (uint64_t)8);
+ if (getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(64*8) &&
+ TyAlign <= ABIAlign) {
return ABIArgInfo::getIndirect(0, /*ByVal=*/true);
}
OpenPOWER on IntegriCloud