TLI = TM->getSubtargetImpl(F)->getTargetLowering();
SmallVector<Instruction *, 1> AtomicInsts;
- SmallVector<LoadInst*, 1> MonotonicLoadInsts;
// Changing control-flow while iterating through it is a bad idea, so gather a
// list of all atomic instructions before we start.
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
- // XXX-update: For relaxed loads, change them to acquire. This includes
- // relaxed loads, relaxed atomic RMW & relaxed atomic compare exchange.
+ // XXX-update: For relaxed loads, mark if the relaxed load is right before
+ // an AcquireRelease RMW operation.
if (I->isAtomic()) {
switch (I->getOpcode()) {
- case Instruction::AtomicCmpXchg: {
- // XXX-comment: AtomicCmpXchg in AArch64 will be translated to a
- // conditional branch that contains the value of the load anyway, so
- // we don't need to do anything.
- /*
- auto* CmpXchg = dyn_cast<AtomicCmpXchgInst>(&*I);
- auto SuccOrdering = CmpXchg->getSuccessOrdering();
- if (SuccOrdering == Monotonic) {
- CmpXchg->setSuccessOrdering(Acquire);
- } else if (SuccOrdering == Release) {
- CmpXchg->setSuccessOrdering(AcquireRelease);
- }
- */
- break;
- }
- case Instruction::AtomicRMW: {
- // XXX-comment: Similar to AtomicCmpXchg. These instructions in
- // AArch64 will be translated to a loop whose condition depends on the
- // store status, which further depends on the load value.
- /*
- auto* RMW = dyn_cast<AtomicRMWInst>(&*I);
- if (RMW->getOrdering() == Monotonic) {
- RMW->setOrdering(Acquire);
- }
- */
- break;
- }
case Instruction::Load: {
auto* LI = dyn_cast<LoadInst>(&*I);
if (LI->getOrdering() == Monotonic) {
- /*
- DEBUG(dbgs() << "Transforming relaxed loads to acquire loads: "
- << *LI << '\n');
- LI->setOrdering(Acquire);
- */
-// MonotonicLoadInsts.push_back(LI);
MarkRelaxedLoadBeforeAcqrelRMW(LI);
}
break;
if (TLI->getInsertFencesForAtomic()) {
if (LI && isAtLeastAcquire(LI->getOrdering())) {
FenceOrdering = LI->getOrdering();
-// AddFakeConditionalBranch(
+ LI->setOrdering(Monotonic);
IsStore = false;
IsLoad = true;
} else if (SI && isAtLeastRelease(SI->getOrdering())) {
MadeChange |= expandAtomicCmpXchg(CASI);
}
}
-
return MadeChange;
}