diff options
author | Daniel Cederman <cederman@gaisler.com> | 2018-07-16 12:14:17 +0000 |
---|---|---|
committer | Daniel Cederman <cederman@gaisler.com> | 2018-07-16 12:14:17 +0000 |
commit | c3d8002c2e1b41a05095f6a0f2e720fa9bb63c00 (patch) | |
tree | ab6579930e17321a84e81abd777d57218f7ba968 /llvm/lib/CodeGen | |
parent | e66a6f48e314c84d00e9580fa3d30fadb683dd11 (diff) | |
download | bcm5719-llvm-c3d8002c2e1b41a05095f6a0f2e720fa9bb63c00.tar.gz bcm5719-llvm-c3d8002c2e1b41a05095f6a0f2e720fa9bb63c00.zip |
Avoid losing Hi part when expanding VAARG nodes on big endian machines
Summary:
If the high part of the load is not used the offset to the next element
will not be set correctly.
For example, on Sparc V8, the following code will read val2 from offset 4
instead of 8.
```
int val = __builtin_va_arg(va, long long);
int val2 = __builtin_va_arg(va, int);
```
Reviewers: jyknight
Reviewed By: jyknight
Subscribers: fedor.sergeev, jrtc27, llvm-commits
Differential Revision: https://reviews.llvm.org/D48595
llvm-svn: 337161
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp index de0f2aa32f4..df3134828af 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp @@ -300,6 +300,7 @@ void DAGTypeLegalizer::ExpandRes_VAARG(SDNode *N, SDValue &Lo, SDValue &Hi) { Lo = DAG.getVAArg(NVT, dl, Chain, Ptr, N->getOperand(2), Align); Hi = DAG.getVAArg(NVT, dl, Lo.getValue(1), Ptr, N->getOperand(2), 0); + Chain = Hi.getValue(1); // Handle endianness of the load. if (TLI.hasBigEndianPartOrdering(OVT, DAG.getDataLayout())) @@ -307,7 +308,7 @@ void DAGTypeLegalizer::ExpandRes_VAARG(SDNode *N, SDValue &Lo, SDValue &Hi) { // Modified the chain - switch anything that used the old chain to use // the new one. - ReplaceValueWith(SDValue(N, 1), Hi.getValue(1)); + ReplaceValueWith(SDValue(N, 1), Chain); } |