aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-09-13 20:50:54 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-09-13 20:50:54 +0000
commitfe731214d2529f7b30527fc312964af411867dd0 (patch)
treed9b8608e93da3dadec9d22943591070982464845
parent7782a58b87923cc293d4e4422729ac0a582bb5c1 (diff)
downloadexternal_llvm-fe731214d2529f7b30527fc312964af411867dd0.zip
external_llvm-fe731214d2529f7b30527fc312964af411867dd0.tar.gz
external_llvm-fe731214d2529f7b30527fc312964af411867dd0.tar.bz2
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
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp11
-rw-r--r--test/CodeGen/X86/atomic-load-store-wide.ll4
2 files changed, 11 insertions, 4 deletions
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 @@ void SelectionDAGBuilder::visitAtomicLoad(const LoadInst &I) {
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 @@ void SelectionDAGBuilder::visitAtomicStore(const StoreInst &I) {
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()),
diff --git a/test/CodeGen/X86/atomic-load-store-wide.ll b/test/CodeGen/X86/atomic-load-store-wide.ll
index 227883e..a9ebfef 100644
--- a/test/CodeGen/X86/atomic-load-store-wide.ll
+++ b/test/CodeGen/X86/atomic-load-store-wide.ll
@@ -7,13 +7,13 @@ define void @test1(i64* %ptr, i64 %val1) {
; CHECK: test1
; CHECK: cmpxchg8b
; CHECK-NEXT: jne
- store atomic i64 %val1, i64* %ptr seq_cst, align 4
+ store atomic i64 %val1, i64* %ptr seq_cst, align 8
ret void
}
define i64 @test2(i64* %ptr) {
; CHECK: test2
; CHECK: cmpxchg8b
- %val = load atomic i64* %ptr seq_cst, align 4
+ %val = load atomic i64* %ptr seq_cst, align 8
ret i64 %val
}