-// XXX-comment: Returns whether the code has been changed.
-bool taintMonotonicLoads(const SmallVector<LoadInst*, 1>& MonotonicLoadInsts) {
- bool Changed = false;
- for (auto* LI : MonotonicLoadInsts) {
- SmallVector<BasicBlock*, 2> ChainedBB;
- auto* FirstInst = findFirstStoreCondBranchInst(LI, &ChainedBB);
- if (FirstInst == nullptr) {
- // We don't seem to be able to taint a following store/conditional branch
- // instruction. Simply make it acquire.
- DEBUG(dbgs() << "[RelaxedLoad]: Transformed to acquire load\n"
- << *LI << "\n");
- LI->setOrdering(Acquire);
- Changed = true;
- continue;
- }
- // Taint 'FirstInst', which could be a store or a condition branch
- // instruction.
- if (FirstInst->getOpcode() == Instruction::Store) {
- Changed |= taintStoreAddress(dyn_cast<StoreInst>(FirstInst), LI);
- } else if (FirstInst->getOpcode() == Instruction::Br) {
- Changed |= taintConditionalBranch(dyn_cast<BranchInst>(FirstInst), LI);
- } else {
- assert(false && "findFirstStoreCondBranchInst() should return a "
- "store/condition branch instruction");
- }
- }
- return Changed;
-}
-