From a86ada86314717be0e10199360a1d282ef1c604a Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Sat, 1 Feb 2020 13:28:02 -0800 Subject: [PATCH] Fix a crash bug when lowering unordered loads to cmpxchg (rhbz1797127) --- ...-a-crash-bug-when-lowering-unordered.patch | 28 +++++++++++++++++++ llvm.spec | 6 +++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 0001-AtomicExpand-Fix-a-crash-bug-when-lowering-unordered.patch diff --git a/0001-AtomicExpand-Fix-a-crash-bug-when-lowering-unordered.patch b/0001-AtomicExpand-Fix-a-crash-bug-when-lowering-unordered.patch new file mode 100644 index 0000000..2d5ca7e --- /dev/null +++ b/0001-AtomicExpand-Fix-a-crash-bug-when-lowering-unordered.patch @@ -0,0 +1,28 @@ +From 2153c4b8281c1e5f25887ef9183947198c50a9d2 Mon Sep 17 00:00:00 2001 +From: Philip Reames +Date: Tue, 19 Mar 2019 17:20:49 +0000 +Subject: [PATCH] [AtomicExpand] Fix a crash bug when lowering unordered loads + to cmpxchg + +Add tests for wider atomic loads and stores. In the process, fix a crasher where we appearently handled unorder stores, but not loads, when lowering to cmpxchg idioms. + +llvm-svn: 356482 +--- + lib/CodeGen/AtomicExpandPass.cpp | 3 + + test/CodeGen/X86/atomic-unordered.ll | 234 +++++++++++++++++++--- + 2 files changed, 213 insertions(+), 24 deletions(-) + +diff --git a/lib/CodeGen/AtomicExpandPass.cpp b/lib/CodeGen/AtomicExpandPass.cpp +index 10dd21d1ef9d..7a8013abccfb 100644 +--- a/lib/CodeGen/AtomicExpandPass.cpp ++++ b/lib/CodeGen/AtomicExpandPass.cpp +@@ -430,6 +430,9 @@ bool AtomicExpand::expandAtomicLoadToLL(LoadInst *LI) { + bool AtomicExpand::expandAtomicLoadToCmpXchg(LoadInst *LI) { + IRBuilder<> Builder(LI); + AtomicOrdering Order = LI->getOrdering(); ++ if (Order == AtomicOrdering::Unordered) ++ Order = AtomicOrdering::Monotonic; ++ + Value *Addr = LI->getPointerOperand(); + Type *Ty = cast(Addr->getType())->getElementType(); + Constant *DummyVal = Constant::getNullValue(Ty); diff --git a/llvm.spec b/llvm.spec index cf34033..f864098 100644 --- a/llvm.spec +++ b/llvm.spec @@ -40,7 +40,7 @@ Name: %{pkg_name} Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 6%{?rc_ver:.rc%{rc_ver}}%{?dist} +Release: 7%{?rc_ver:.rc%{rc_ver}}%{?dist} Summary: The Low Level Virtual Machine License: NCSA @@ -52,6 +52,7 @@ Source2: lit.fedora.cfg.py Patch5: 0001-PATCH-llvm-config.patch Patch7: 0001-PATCH-Filter-out-cxxflags-not-supported-by-clang.patch Patch8: 0001-Fix-the-buildbot-issue-introduced-by-r351421.patch +Patch9: 0001-AtomicExpand-Fix-a-crash-bug-when-lowering-unordered.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -462,6 +463,9 @@ fi %endif %changelog +* Sat Feb 01 2020 Josh Stone - 8.0.0-7 +- Fix a crash bug when lowering unordered loads to cmpxchg (rhbz1797127) + * Wed Apr 24 2019 Tom Stellard - 8.0.0-6 - Make sure we aren't passing -g on s390x