forked from OSchip/llvm-project
[Attributor] Cleanup detection of non-relaxed atomics in nosync inference
The code was checking for cases which are disallowed by the verifier. Delete dead code and adjust style.
This commit is contained in:
parent
8e596f7e27
commit
1e69a5af92
|
@ -1290,6 +1290,15 @@ bool AANoSyncImpl::isNonRelaxedAtomic(Instruction *I) {
|
||||||
if (!I->isAtomic())
|
if (!I->isAtomic())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (auto *FI = dyn_cast<FenceInst>(I))
|
||||||
|
// All legal orderings for fence are stronger than monotonic.
|
||||||
|
return FI->getSyncScopeID() != SyncScope::SingleThread;
|
||||||
|
else if (auto *AI = dyn_cast<AtomicCmpXchgInst>(I)) {
|
||||||
|
// Unordered is not a legal ordering for cmpxchg.
|
||||||
|
return (AI->getSuccessOrdering() != AtomicOrdering::Monotonic ||
|
||||||
|
AI->getFailureOrdering() != AtomicOrdering::Monotonic);
|
||||||
|
}
|
||||||
|
|
||||||
AtomicOrdering Ordering;
|
AtomicOrdering Ordering;
|
||||||
switch (I->getOpcode()) {
|
switch (I->getOpcode()) {
|
||||||
case Instruction::AtomicRMW:
|
case Instruction::AtomicRMW:
|
||||||
|
@ -1301,36 +1310,13 @@ bool AANoSyncImpl::isNonRelaxedAtomic(Instruction *I) {
|
||||||
case Instruction::Load:
|
case Instruction::Load:
|
||||||
Ordering = cast<LoadInst>(I)->getOrdering();
|
Ordering = cast<LoadInst>(I)->getOrdering();
|
||||||
break;
|
break;
|
||||||
case Instruction::Fence: {
|
|
||||||
auto *FI = cast<FenceInst>(I);
|
|
||||||
if (FI->getSyncScopeID() == SyncScope::SingleThread)
|
|
||||||
return false;
|
|
||||||
Ordering = FI->getOrdering();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Instruction::AtomicCmpXchg: {
|
|
||||||
AtomicOrdering Success = cast<AtomicCmpXchgInst>(I)->getSuccessOrdering();
|
|
||||||
AtomicOrdering Failure = cast<AtomicCmpXchgInst>(I)->getFailureOrdering();
|
|
||||||
// Only if both are relaxed, than it can be treated as relaxed.
|
|
||||||
// Otherwise it is non-relaxed.
|
|
||||||
if (Success != AtomicOrdering::Unordered &&
|
|
||||||
Success != AtomicOrdering::Monotonic)
|
|
||||||
return true;
|
|
||||||
if (Failure != AtomicOrdering::Unordered &&
|
|
||||||
Failure != AtomicOrdering::Monotonic)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
llvm_unreachable(
|
llvm_unreachable(
|
||||||
"New atomic operations need to be known in the attributor.");
|
"New atomic operations need to be known in the attributor.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relaxed.
|
return (Ordering != AtomicOrdering::Unordered &&
|
||||||
if (Ordering == AtomicOrdering::Unordered ||
|
Ordering != AtomicOrdering::Monotonic);
|
||||||
Ordering == AtomicOrdering::Monotonic)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return true if this intrinsic is nosync. This is only used for intrinsics
|
/// Return true if this intrinsic is nosync. This is only used for intrinsics
|
||||||
|
|
Loading…
Reference in New Issue