Error out on CodeGen of unaligned load/store.  Fix test so it isn't accidentally testing that case.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139641 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index e0c0fc2..4c58fe9 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -3402,6 +3402,9 @@
 
   EVT VT = EVT::getEVT(I.getType());
 
+  if (I.getAlignment() * 8 != VT.getSizeInBits())
+    report_fatal_error("Cannot generate unaligned atomic load");
+
   SDValue L =
     DAG.getAtomic(ISD::ATOMIC_LOAD, dl, VT, VT, InChain,
                   getValue(I.getPointerOperand()),
@@ -3427,13 +3430,17 @@
 
   SDValue InChain = getRoot();
 
+  EVT VT = EVT::getEVT(I.getValueOperand()->getType());
+
+  if (I.getAlignment() * 8 != VT.getSizeInBits())
+    report_fatal_error("Cannot generate unaligned atomic store");
+
   if (TLI.getInsertFencesForAtomic())
     InChain = InsertFenceForAtomic(InChain, Order, Scope, true, dl,
                                    DAG, TLI);
 
   SDValue OutChain =
-    DAG.getAtomic(ISD::ATOMIC_STORE, dl,
-                  getValue(I.getValueOperand()).getValueType().getSimpleVT(),
+    DAG.getAtomic(ISD::ATOMIC_STORE, dl, VT,
                   InChain,
                   getValue(I.getPointerOperand()),
                   getValue(I.getValueOperand()),