forked from OSchip/llvm-project
AtomicExpand: Add NotAtomic lowering strategy
Currently LowerAtomics exists as a separate pass which blindly replaces all atomics. Add a new lowering strategy option to eliminate the atomics which the target can control on a per-instruction level.
This commit is contained in:
parent
c4ea925f50
commit
7f14a1d46b
|
@ -257,6 +257,10 @@ public:
|
|||
BitTestIntrinsic, // Use a target-specific intrinsic for special bit
|
||||
// operations; used by X86.
|
||||
Expand, // Generic expansion in terms of other atomic operations.
|
||||
|
||||
// Rewrite to a non-atomic form for use in a known non-preemptible
|
||||
// environment.
|
||||
NotAtomic
|
||||
};
|
||||
|
||||
/// Enum that specifies when a multiplication should be expanded.
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Utils/LowerAtomic.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
|
@ -412,6 +413,9 @@ bool AtomicExpand::tryExpandAtomicLoad(LoadInst *LI) {
|
|||
return expandAtomicLoadToLL(LI);
|
||||
case TargetLoweringBase::AtomicExpansionKind::CmpXChg:
|
||||
return expandAtomicLoadToCmpXchg(LI);
|
||||
case TargetLoweringBase::AtomicExpansionKind::NotAtomic:
|
||||
LI->setAtomic(AtomicOrdering::NotAtomic);
|
||||
return true;
|
||||
default:
|
||||
llvm_unreachable("Unhandled case in tryExpandAtomicLoad");
|
||||
}
|
||||
|
@ -424,6 +428,9 @@ bool AtomicExpand::tryExpandAtomicStore(StoreInst *SI) {
|
|||
case TargetLoweringBase::AtomicExpansionKind::Expand:
|
||||
expandAtomicStore(SI);
|
||||
return true;
|
||||
case TargetLoweringBase::AtomicExpansionKind::NotAtomic:
|
||||
SI->setAtomic(AtomicOrdering::NotAtomic);
|
||||
return true;
|
||||
default:
|
||||
llvm_unreachable("Unhandled case in tryExpandAtomicStore");
|
||||
}
|
||||
|
@ -635,6 +642,8 @@ bool AtomicExpand::tryExpandAtomicRMW(AtomicRMWInst *AI) {
|
|||
TLI->emitBitTestAtomicRMWIntrinsic(AI);
|
||||
return true;
|
||||
}
|
||||
case TargetLoweringBase::AtomicExpansionKind::NotAtomic:
|
||||
return lowerAtomicRMWInst(AI);
|
||||
default:
|
||||
llvm_unreachable("Unhandled case in tryExpandAtomicRMW");
|
||||
}
|
||||
|
@ -1536,6 +1545,8 @@ bool AtomicExpand::tryExpandAtomicCmpXchg(AtomicCmpXchgInst *CI) {
|
|||
case TargetLoweringBase::AtomicExpansionKind::MaskedIntrinsic:
|
||||
expandAtomicCmpXchgToMaskedIntrinsic(CI);
|
||||
return true;
|
||||
case TargetLoweringBase::AtomicExpansionKind::NotAtomic:
|
||||
return lowerAtomicCmpXchgInst(CI);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue