summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorCameron Zwarich <zwarich@apple.com>2011-03-16 22:20:18 +0000
committerCameron Zwarich <zwarich@apple.com>2011-03-16 22:20:18 +0000
commitac106273d4ff77d259a63e82771aec29ca11ec1a (patch)
treef5739f4fc3624d1cf9b5c27adc9ce0e8c5c5861f /llvm/lib/CodeGen
parent40a9200357099c7ef0480abb5a135239a83bfb35 (diff)
downloadbcm5719-llvm-ac106273d4ff77d259a63e82771aec29ca11ec1a.tar.gz
bcm5719-llvm-ac106273d4ff77d259a63e82771aec29ca11ec1a.zip
The x86-64 ABI says that a bool is only guaranteed to be sign-extended to a byte
rather than an int. Thankfully, this only causes LLVM to miss optimizations, not generate incorrect code. This just fixes the zext at the return. We still insert an i32 ZextAssert when reading a function's arguments, but it is followed by a truncate and another i8 ZextAssert so it is not optimized. llvm-svn: 127766
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index aa7009ac395..55483188355 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1128,12 +1128,9 @@ void SelectionDAGBuilder::visitRet(const ReturnInst &I) {
else if (F->paramHasAttr(0, Attribute::ZExt))
ExtendKind = ISD::ZERO_EXTEND;
- // FIXME: C calling convention requires the return type to be promoted
- // to at least 32-bit. But this is not necessary for non-C calling
- // conventions. The frontend should mark functions whose return values
- // require promoting with signext or zeroext attributes.
if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger()) {
- EVT MinVT = TLI.getRegisterType(*DAG.getContext(), MVT::i32);
+ MVT ReturnMVT = TLI.getTypeForExtendedInteger(VT, ExtendKind);
+ EVT MinVT = TLI.getRegisterType(*DAG.getContext(), ReturnMVT);
if (VT.bitsLT(MinVT))
VT = MinVT;
}
OpenPOWER on IntegriCloud