fixed cmpexchg bug by passing in const bool field
This commit is contained in:
15
cbackend.cpp
15
cbackend.cpp
@@ -501,8 +501,12 @@ namespace {
|
|||||||
static bool isInlinableInst(const llvm::Instruction &I) {
|
static bool isInlinableInst(const llvm::Instruction &I) {
|
||||||
// Always inline cmp instructions, even if they are shared by multiple
|
// Always inline cmp instructions, even if they are shared by multiple
|
||||||
// expressions. GCC generates horrible code if we don't.
|
// expressions. GCC generates horrible code if we don't.
|
||||||
if (llvm::isa<llvm::CmpInst>(I) && llvm::isa<llvm::VectorType>(I.getType()) == false)
|
if (llvm::isa<llvm::CmpInst>(I) && llvm::isa<llvm::VectorType>(I.getType()) == false)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// This instruction returns a struct, which can not be inlined
|
||||||
|
if (llvm::isa<llvm::AtomicCmpXchgInst>(I))
|
||||||
|
return false;
|
||||||
|
|
||||||
// Must be an expression, must be used exactly once. If it is dead, we
|
// Must be an expression, must be used exactly once. If it is dead, we
|
||||||
// emit it inline where it would go.
|
// emit it inline where it would go.
|
||||||
@@ -4504,14 +4508,17 @@ void CWriter::visitAtomicRMWInst(llvm::AtomicRMWInst &AI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) {
|
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(";
|
Out << "__atomic_cmpxchg(";
|
||||||
writeOperand(ACXI.getPointerOperand());
|
writeOperand(ACXI.getPointerOperand());
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
writeOperand(ACXI.getCompareOperand());
|
writeOperand(ACXI.getCompareOperand());
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
writeOperand(ACXI.getNewValOperand());
|
writeOperand(ACXI.getNewValOperand());
|
||||||
Out << "))";
|
Out << "), ";
|
||||||
|
Out << "true"; // The result of the instruction is always success
|
||||||
|
Out << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user