From 8eeeebf091aa2097bdf99036748ed5ab7f35ce1e Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Thu, 12 Feb 2015 13:44:45 +0300 Subject: [PATCH 1/4] fixed cmpexchg bug by passing in const bool field --- cbackend.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cbackend.cpp b/cbackend.cpp index be324934..4c13ba20 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -501,8 +501,12 @@ namespace { static bool isInlinableInst(const llvm::Instruction &I) { // Always inline cmp instructions, even if they are shared by multiple // expressions. GCC generates horrible code if we don't. - if (llvm::isa(I) && llvm::isa(I.getType()) == false) - return true; + if (llvm::isa(I) && llvm::isa(I.getType()) == false) + return true; + + // This instruction returns a struct, which can not be inlined + if (llvm::isa(I)) + return false; // Must be an expression, must be used exactly once. If it is dead, we // emit it inline where it would go. @@ -4504,14 +4508,17 @@ void CWriter::visitAtomicRMWInst(llvm::AtomicRMWInst &AI) { } void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) { - Out << "("; + printType(Out, ACXI.getType(), false); + Out << "::init("; // LLVM cmpxchg returns a struct, so we need make an assighment properly Out << "__atomic_cmpxchg("; writeOperand(ACXI.getPointerOperand()); Out << ", "; writeOperand(ACXI.getCompareOperand()); Out << ", "; writeOperand(ACXI.getNewValOperand()); - Out << "))"; + Out << "), "; + Out << "true"; // The result of the instruction is always success + Out << ")"; } /////////////////////////////////////////////////////////////////////////// From 280675eb80d200e04e15c2b8539ec6778f24204d Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Thu, 12 Feb 2015 15:10:38 +0300 Subject: [PATCH 2/4] add comments regarding constant 'true' field --- cbackend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cbackend.cpp b/cbackend.cpp index 4c13ba20..4afc60e5 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -4517,7 +4517,7 @@ void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) { Out << ", "; writeOperand(ACXI.getNewValOperand()); Out << "), "; - Out << "true"; // The result of the instruction is always success + Out << "true /* There is no way to learn the value of this bit inside ISPC, so making it constant */"; Out << ")"; } From 8cf7445b93bf5dd1dff146b77bc6dcb5decfd3e7 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Thu, 12 Feb 2015 17:59:44 +0300 Subject: [PATCH 3/4] add ifdefs for pre-3.5 LLVM versions (where cmpxchg had different defenition) --- cbackend.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cbackend.cpp b/cbackend.cpp index 4afc60e5..153cdc2c 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -504,9 +504,11 @@ namespace { if (llvm::isa(I) && llvm::isa(I.getType()) == false) return true; - // This instruction returns a struct, which can not be inlined +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ + // This instruction returns a struct on LLVM older than 3.4, and can not be inlined if (llvm::isa(I)) return false; +#endif // Must be an expression, must be used exactly once. If it is dead, we // emit it inline where it would go. @@ -4508,16 +4510,21 @@ void CWriter::visitAtomicRMWInst(llvm::AtomicRMWInst &AI) { } void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) { + Out << "("; +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) printType(Out, ACXI.getType(), false); Out << "::init("; // LLVM cmpxchg returns a struct, so we need make an assighment properly +#endif Out << "__atomic_cmpxchg("; writeOperand(ACXI.getPointerOperand()); Out << ", "; writeOperand(ACXI.getCompareOperand()); Out << ", "; writeOperand(ACXI.getNewValOperand()); - Out << "), "; - Out << "true /* There is no way to learn the value of this bit inside ISPC, so making it constant */"; + Out << ")"; +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) + Out << ", true /* There is no way to learn the value of this bit inside ISPC, so making it constant */)"; +#endif Out << ")"; } From 3dbc5ba6c27430a39c3c7173a49ed6df9758cc8b Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Thu, 12 Feb 2015 18:19:35 +0300 Subject: [PATCH 4/4] update fail_db.txt --- fail_db.txt | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/fail_db.txt b/fail_db.txt index 6f66260b..58383450 100644 --- a/fail_db.txt +++ b/fail_db.txt @@ -560,11 +560,8 @@ ./tests/aossoa-7.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * ./tests/aossoa-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * ./tests/atomics-13.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * -./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O2 * ./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * -./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O2 * ./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * -./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O2 * ./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * ./tests/funcptr-varying-7.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * ./tests/funcptr-varying-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * @@ -651,13 +648,10 @@ ./tests/atomics-3.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * ./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 * ./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * -./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 * ./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * ./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 * ./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * -./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 * ./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * -./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 * ./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * ./tests/exclusive-scan-add-1.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * ./tests/exclusive-scan-add-10.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * @@ -730,11 +724,8 @@ ./tests/aossoa-7.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * ./tests/aossoa-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * ./tests/atomics-13.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * -./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 * ./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * -./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 * ./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * -./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 * ./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * ./tests/funcptr-varying-7.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * ./tests/funcptr-varying-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * @@ -821,13 +812,10 @@ ./tests/atomics-3.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * ./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 * ./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * -./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 * ./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * ./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 * ./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * -./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 * ./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * -./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 * ./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * ./tests/exclusive-scan-add-1.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * ./tests/exclusive-scan-add-10.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * @@ -1014,9 +1002,6 @@ ./tests/exclusive-scan-add-7.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 * ./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * ./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * -./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * -./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * -./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * ./tests/exclusive-scan-add-1.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * ./tests/exclusive-scan-add-10.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * ./tests/exclusive-scan-add-2.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * @@ -1042,7 +1027,4 @@ ./tests/atomics-2.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 * ./tests/atomics-3.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 * ./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 * -./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 * ./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 * -./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 * -./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 *