summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJonas Paulsson <paulsson@linux.vnet.ibm.com>2017-11-30 08:18:50 +0000
committerJonas Paulsson <paulsson@linux.vnet.ibm.com>2017-11-30 08:18:50 +0000
commitb9a2467501789390bc5376e0d3cb1e1f2fffb624 (patch)
tree0eddcba3e39426cf5dfbbb95f26a983ab59682a2 /llvm/lib
parent527b3966d0e5fd25bce79b2409cd1a317563d338 (diff)
downloadbcm5719-llvm-b9a2467501789390bc5376e0d3cb1e1f2fffb624.tar.gz
bcm5719-llvm-b9a2467501789390bc5376e0d3cb1e1f2fffb624.zip
[SystemZ] Bugfix in adjustSubwordCmp.
Csmith generated a program where a store after load to the same address did not get chained after the new load created during DAG legalizing, and so performed an illegal overwrite of the expected value. When the new zero-extending load is created, the chain users of the original load must be updated, which was not done previously. A similar case was also found and handled in lowerBITCAST. Review: Ulrich Weigand https://reviews.llvm.org/D40542 llvm-svn: 319409
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/SystemZ/SystemZISelLowering.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index d49d7316e68..ad14e5e34e2 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -1844,11 +1844,14 @@ static void adjustSubwordCmp(SelectionDAG &DAG, const SDLoc &DL,
ISD::SEXTLOAD :
ISD::ZEXTLOAD);
if (C.Op0.getValueType() != MVT::i32 ||
- Load->getExtensionType() != ExtType)
+ Load->getExtensionType() != ExtType) {
C.Op0 = DAG.getExtLoad(ExtType, SDLoc(Load), MVT::i32, Load->getChain(),
Load->getBasePtr(), Load->getPointerInfo(),
Load->getMemoryVT(), Load->getAlignment(),
Load->getMemOperand()->getFlags());
+ // Update the chain uses.
+ DAG.ReplaceAllUsesOfValueWith(SDValue(Load, 1), C.Op0.getValue(1));
+ }
// Make sure that the second operand is an i32 with the right value.
if (C.Op1.getValueType() != MVT::i32 ||
@@ -2940,9 +2943,13 @@ SDValue SystemZTargetLowering::lowerBITCAST(SDValue Op,
// but we need this case for bitcasts that are created during lowering
// and which are then lowered themselves.
if (auto *LoadN = dyn_cast<LoadSDNode>(In))
- if (ISD::isNormalLoad(LoadN))
- return DAG.getLoad(ResVT, DL, LoadN->getChain(), LoadN->getBasePtr(),
- LoadN->getMemOperand());
+ if (ISD::isNormalLoad(LoadN)) {
+ SDValue NewLoad = DAG.getLoad(ResVT, DL, LoadN->getChain(),
+ LoadN->getBasePtr(), LoadN->getMemOperand());
+ // Update the chain uses.
+ DAG.ReplaceAllUsesOfValueWith(SDValue(LoadN, 1), NewLoad.getValue(1));
+ return NewLoad;
+ }
if (InVT == MVT::i32 && ResVT == MVT::f32) {
SDValue In64;
OpenPOWER on IntegriCloud