From: Tim Northover Date: Fri, 10 May 2019 11:23:04 +0000 (+0000) Subject: SelectionDAG: accommodate atomic floating stores. X-Git-Tag: android-x86-9.0-r1~3605 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=06b700153b4824d7cf3d8f206b14e264b8535065;p=android-x86%2Fexternal-llvm.git SelectionDAG: accommodate atomic floating stores. We were applying a pointer truncation to floating types, which crashed LLVM. That is Not A Good Thing(TM). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360421 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 75349cb8e3b..e58b0d22d9a 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4717,7 +4717,10 @@ void SelectionDAGBuilder::visitAtomicStore(const StoreInst &I) { MemVT.getStoreSize(), I.getAlignment(), AAMDNodes(), nullptr, SSID, Ordering); - SDValue Val = DAG.getPtrExtOrTrunc(getValue(I.getValueOperand()), dl, MemVT); + SDValue Val = getValue(I.getValueOperand()); + if (Val.getValueType() != MemVT) + Val = DAG.getPtrExtOrTrunc(Val, dl, MemVT); + SDValue OutChain = DAG.getAtomic(ISD::ATOMIC_STORE, dl, MemVT, InChain, getValue(I.getPointerOperand()), Val, MMO); diff --git a/test/CodeGen/NVPTX/load-store.ll b/test/CodeGen/NVPTX/load-store.ll index 03b0109dea2..a3fb172646a 100644 --- a/test/CodeGen/NVPTX/load-store.ll +++ b/test/CodeGen/NVPTX/load-store.ll @@ -59,7 +59,7 @@ define void @volatile(i8* %a, i16* %b, i32* %c, i64* %d) local_unnamed_addr { } ; CHECK-LABEL: monotonic -define void @monotonic(i8* %a, i16* %b, i32* %c, i64* %d) local_unnamed_addr { +define void @monotonic(i8* %a, i16* %b, i32* %c, i64* %d, float* %e) local_unnamed_addr { ; CHECK: ld.volatile.u8 %rs{{[0-9]+}}, [%rd{{[0-9]+}}] %a.load = load atomic i8, i8* %a monotonic, align 1 %a.add = add i8 %a.load, 1 @@ -84,5 +84,11 @@ define void @monotonic(i8* %a, i16* %b, i32* %c, i64* %d) local_unnamed_addr { ; CHECK: st.volatile.u64 [%rd{{[0-9]+}}], %rd{{[0-9]+}} store atomic i64 %d.add, i64* %d monotonic, align 8 + ; CHECK: ld.volatile.f32 %f{{[0-9]+}}, [%rd{{[0-9]+}}] + %e.load = load atomic float, float* %e monotonic, align 4 + %e.add = fadd float %e.load, 1.0 + ; CHECK: st.volatile.f32 [%rd{{[0-9]+}}], %f{{[0-9]+}} + store atomic float %e.add, float* %e monotonic, align 4 + ret void }