Type * VoidTy;
static const size_t kNumberOfAccessSizes = 4;
-static const int volatile_order = 6;
int getAtomicOrderIndex(AtomicOrdering order){
switch (order) {
CDSLoad[i] = M.getOrInsertFunction(LoadName, VoidTy, PtrTy);
CDSStore[i] = M.getOrInsertFunction(StoreName, VoidTy, PtrTy);
CDSVolatileLoad[i] = M.getOrInsertFunction(VolatileLoadName,
- Ty, PtrTy, OrdTy, Int8PtrTy);
+ Ty, PtrTy, Int8PtrTy);
CDSVolatileStore[i] = M.getOrInsertFunction(VolatileStoreName,
- VoidTy, PtrTy, Ty, OrdTy, Int8PtrTy);
+ VoidTy, PtrTy, Ty, Int8PtrTy);
CDSAtomicInit[i] = M.getOrInsertFunction(AtomicInitName,
VoidTy, PtrTy, Ty, Int8PtrTy);
CDSAtomicLoad[i] = M.getOrInsertFunction(AtomicLoadName,
bool Res = false;
bool HasAtomic = false;
+ bool HasVolatile = false;
const DataLayout &DL = F.getParent()->getDataLayout();
// errs() << "--- " << F.getName() << "---\n";
StoreInst *SI = dyn_cast<StoreInst>(&I);
bool isVolatile = ( LI ? LI->isVolatile() : SI->isVolatile() );
- if (isVolatile)
+ if (isVolatile) {
VolatileLoadsAndStores.push_back(&I);
- else
+ HasVolatile = true;
+ } else
LocalLoadsAndStores.push_back(&I);
} else if (isa<CallInst>(I) || isa<InvokeInst>(I)) {
// not implemented yet
}
// only instrument functions that contain atomics
- if (Res && HasAtomic) {
+ if (Res && ( HasAtomic || HasVolatile) ) {
IRBuilder<> IRB(F.getEntryBlock().getFirstNonPHI());
/* Unused for now
Value *ReturnAddress = IRB.CreateCall(
Res = true;
}
-
- F.dump();
}
return false;
if (Idx < 0)
return false;
- Value *order = ConstantInt::get(OrdTy, volatile_order);
- Value *args[] = {Addr, order, position};
+ Value *args[] = {Addr, position};
Instruction* funcInst=CallInst::Create(CDSVolatileLoad[Idx], args);
ReplaceInstWithInst(LI, funcInst);
} else if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
return false;
Value *val = SI->getValueOperand();
- Value *order = ConstantInt::get(OrdTy, volatile_order);
- Value *args[] = {Addr, val, order, position};
+ Value *args[] = {Addr, val, position};
Instruction* funcInst=CallInst::Create(CDSVolatileStore[Idx], args);
ReplaceInstWithInst(SI, funcInst);
} else {
return true;
} else if (funName.contains("atomic") &&
- funName.contains("EEEE5store") ) {
+ funName.contains("store") ) {
// does this version of call always have an atomic order as an argument?
Value *OrigVal = parameters[1];