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 << ")"; } ///////////////////////////////////////////////////////////////////////////