BasicBlock *Parent;
DebugLoc DbgLoc; // 'dbg' Metadata cache.
+ // XXX-modified: Indicate whether this instruction should be tainted. Used for
+ // tainting the load parts of RMW.
+ bool NeedTainted;
+
enum {
/// HasMetadataBit - This is a bit stored in the SubClassData field which
/// indicates whether this instruction has metadata attached to it or not.
HasMetadataBit = 1 << 15
};
+
public:
// Out of line virtual method, so the vtable, etc has a home.
~Instruction() override;
/// Copy I's fast-math flags
void copyFastMathFlags(const Instruction *I);
+ // XXX-modified: Indicate whether this instruction should be tainted. Used for
+ // tainting the load parts of RMW.
+ bool getNeedTainted() {
+ return NeedTainted;
+ }
+
+ bool setNeedTainted() {
+ NeedTainted = true;
+ }
+
private:
/// hasMetadataHashEntry - Return true if we have an entry in the on-the-side
/// metadata hash.
// Start the main loop block now that we've taken care of the preliminaries.
Builder.SetInsertPoint(LoopBB);
Value *Loaded = TLI->emitLoadLinked(Builder, Addr, MemOpOrder);
+ auto* LoadedPartInst = dyn_cast<Instruction>(Loaded);
+ assert(LoadedPartInst && "Load part of RMW should be an instruction!");
+ if (MemOpOrder != Acquire && MemOpOrder != AcquireRelease &&
+ MemOpOrder != SequentiallyConsistent) {
+ LoadedPartInst->setNeedTainted();
+ }
Value *NewVal = PerformOp(Builder, Loaded);
break;
}
}
+ } else if (I->getNeedTainted()) {
+ TaintRelaxedLoads(&*I, I->getNextNode());
}
}
EverMadeChange |=
Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
Instruction *InsertBefore)
- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
+ : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr),
+ NeedTainted(false) {
// If requested, insert this instruction into a basic block...
if (InsertBefore) {
Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
BasicBlock *InsertAtEnd)
- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
+ : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr),
+ NeedTainted(false) {
// append this instruction into the basic block
assert(InsertAtEnd && "Basic block to append to may not be NULL!");