Created
March 20, 2018 22:16
-
-
Save brainlag/bfb4840a12b74b60557f34ed33aa9481 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Target/AVR/AVRISelLowering.cpp b/lib/Target/AVR/AVRISelLowering.cpp | |
index e0bb2f317d1..4dc7efaa51c 100644 | |
--- a/lib/Target/AVR/AVRISelLowering.cpp | |
+++ b/lib/Target/AVR/AVRISelLowering.cpp | |
@@ -1374,7 +1374,24 @@ AVRTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, | |
// Reverse splitted return values to get the "big endian" format required | |
// to agree with the calling convention ABI. | |
if (e > 1) { | |
- std::reverse(RVLocs.begin(), RVLocs.end()); | |
+ // some hackery because SelectionDAGBuilder does not split up arguments properly | |
+ Type *retType = MF.getFunction().getReturnType(); | |
+ if (retType->isStructTy()) { | |
+ if (retType->getNumContainedTypes() > 1 && retType->getNumContainedTypes() > e) { | |
+ for (unsigned i = 0, pos = 0; i < retType->getNumContainedTypes(); ++i) { | |
+ Type *field = retType->getContainedType(i); | |
+ if(field->isIntegerTy() && field->getIntegerBitWidth() > 16) { | |
+ int Size = field->getIntegerBitWidth() / 16; | |
+ std::reverse(RVLocs.begin()+ pos, RVLocs.end() + pos + Size); | |
+ pos += Size; | |
+ } else { | |
+ pos++; | |
+ } | |
+ } | |
+ } | |
+ } else { | |
+ std::reverse(RVLocs.begin(), RVLocs.end()); | |
+ } | |
} | |
SDValue Flag; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment